import sys
import socket

def trans(port, dst, dst_port):
    s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)  
    addr = (dst, dst_port)
    # s.settimeout(5) #
    s.bind(('', port))  
    print("Waiting... @", port)
    while True:
        try:
            s.settimeout(2)
            d,a = s.recvfrom(8192)
            # print(d)
            s.sendto(d, addr)
        except Exception as e:
            print('.', end='', flush=True)
    s.close()

if __name__ == '__main__':
    addr_str = '10.20.88.1'
    port = 30000

    if (len(sys.argv) < 2):
        print(sys.argv[0], ' <port>')
    elif (len(sys.argv) == 2):
        try:
            v = int(sys.argv[1])
            port = v
        except Exception as e:
            print(e)
            addr_str = sys.argv[1]
    elif (len(sys.argv) == 3):
        addr_str = sys.argv[1]
        port = int(sys.argv[2])
    trans(port, addr_str, port)